#!/usr/bin/env python
#
# Copyright (c) 2011 GhostBSD
#
# See COPYING for licence terms.
#
# gbi_summary.py v 0.0 Tuesday, February 22 2011 10:54:53 Eric
#
# gbi_summary.py show the the seting befor install and start the installation.

import pygtk
pygtk.require('2.0')
import gtk
import os, os.path, sys, stat, shutil
class TextViewExample:
    def close_application(self, widget):
		os.system("killall python")
    
    def quit_application(self, widget):
        gtk.main_quit()
        
    def create_bbox(self, horizontal, title, spacing, layout):
        frame = gtk.Frame(title)

        if horizontal:
            bbox = gtk.HButtonBox()
        else:
            bbox = gtk.VButtonBox()

        bbox.set_border_width(5)
        frame.add(bbox)

        # Set the appearance of the Button Box
        bbox.set_layout(layout)
        bbox.set_spacing(spacing)
        
        button = gtk.Button(stock=gtk.STOCK_GO_BACK)
        bbox.add(button)

        button = gtk.Button(stock=gtk.STOCK_CANCEL)
        bbox.add(button)
        button.connect("clicked", self.close_application)
         
        button = gtk.Button("Ginstall")
        bbox.add(button)
        button.connect("clicked", self.quit_application)

        return frame
    
    
        
    def __init__(self):
        window = gtk.Window(gtk.WINDOW_TOPLEVEL)
        window.connect("destroy", self.close_application)
        window.set_size_request(550, 400)  
        window.set_title("GBI Summary")
        window.set_border_width(0)
        window.set_position(gtk.WIN_POS_CENTER)

        try:
            window.set_icon_from_file("G-logo.png")
        except Exception, e:
            print e.message
            sys.exit(1)

        box1 = gtk.VBox(False, 0)
        window.add(box1)
        box1.show()

        box2 = gtk.VBox(False, 10)
        box2.set_border_width(10)
        box1.pack_start(box2, True, True, 0)
        box2.show()

        sw = gtk.ScrolledWindow()
        sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        textview = gtk.TextView()
        textbuffer = textview.get_buffer()
        sw.add(textview)
        sw.show()
        textview.show()

        box2.pack_start(sw)
        # Load the file textview-basic.py into the text window
        infile = open("pcinstall.cfg", "r")

        if infile:
            string = infile.read()
            infile.close()
            textbuffer.set_text(string)
        
        box2 = gtk.HBox(False, 5)
        box2.set_border_width(5)
        box1.pack_start(box2, False, True, 0)
        box2.show()

        
        
        box2.pack_start(self.create_bbox(True, "Installation Summary",
                                         10, gtk.BUTTONBOX_END),
                        True, True, 5)

        
        window.show_all()
        

def main():
    gtk.main()
    return 0       

if __name__ == "__main__":
    TextViewExample()
    main()
